//
//  PopoverPresentationController.m
//  weibo
//
//  Created by hp on 16/4/26.
//  Copyright © 2016年 hp. All rights reserved.
//

#import "PopoverPresentationController.h"

@implementation PopoverPresentationController

// 布局转场子视图调用
- (void)containerViewDidLayoutSubviews
{
    self.presentedView.backgroundColor = [UIColor clearColor]
    ;    // 修改弹出视图的大小
    self.presentedView.frame = self.popoverFrame;
    // 蒙版
    UIView *bgView = [[UIView alloc] init];
    bgView.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.2];
    bgView.frame = [UIScreen mainScreen].bounds;
    [self.containerView insertSubview:bgView atIndex:0];
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapDo:)];
    [self.containerView addGestureRecognizer:tap];
}

- (void)tapDo:(UITapGestureRecognizer *)gesture
{
    [self.presentedViewController dismissViewControllerAnimated:YES completion:nil];
}
@end
